<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>static_resource</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.JSON">
<link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
<link rel="prev" href="boost__json__serializer/read/overload2.html" title="serializer::read (2 of 2 overloads)">
<link rel="next" href="boost__json__static_resource/static_resource.html" title="static_resource::static_resource">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__serializer/read/overload2.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__static_resource/static_resource.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="json.ref.boost__json__static_resource"></a><a class="link" href="boost__json__static_resource.html" title="static_resource">static_resource</a>
</h4></div></div></div>
<p>
        A resource using a caller-owned buffer, with a trivial deallocate.
      </p>
<h5>
<a name="json.ref.boost__json__static_resource.h0"></a>
        <span class="phrase"><a name="json.ref.boost__json__static_resource.synopsis"></a></span><a class="link" href="boost__json__static_resource.html#json.ref.boost__json__static_resource.synopsis">Synopsis</a>
      </h5>
<p>
        Defined in header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json/static_resource.hpp" target="_top">boost/json/static_resource.hpp</a>&gt;</code>
      </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">static_resource</span> <span class="special">:</span>
    <span class="keyword">public</span> <span class="identifier">memory_resource</span>
</pre>
<h5>
<a name="json.ref.boost__json__static_resource.h1"></a>
        <span class="phrase"><a name="json.ref.boost__json__static_resource.member_functions"></a></span><a class="link" href="boost__json__static_resource.html#json.ref.boost__json__static_resource.member_functions">Member Functions</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Name
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__static_resource/operator_eq_.html" title="static_resource::operator=">operator=</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Copy assignment (deleted)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__static_resource/release.html" title="static_resource::release">release</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Release all allocated memory.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__static_resource/static_resource.html" title="static_resource::static_resource">static_resource</a> <span class="silver">[constructor]</span></strong></span>
                </p>
              </td>
<td>
                <p>
                  Constructor. <br> <span class="silver">—</span><br> Copy
                  constructor (deleted)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__static_resource/_dtor_static_resource.html" title="static_resource::~static_resource">~static_resource</a> <span class="silver">[destructor]</span></strong></span>
                </p>
              </td>
<td>
                <p>
                  Destructor.
                </p>
              </td>
</tr>
</tbody>
</table></div>
<h5>
<a name="json.ref.boost__json__static_resource.h2"></a>
        <span class="phrase"><a name="json.ref.boost__json__static_resource.description"></a></span><a class="link" href="boost__json__static_resource.html#json.ref.boost__json__static_resource.description">Description</a>
      </h5>
<p>
        This memory resource is a special-purpose resource that releases allocated
        memory only when the resource is destroyed (or when <a class="link" href="boost__json__static_resource/release.html" title="static_resource::release"><code class="computeroutput"><span class="identifier">release</span></code></a> is called). It has a trivial
        deallocate function; that is, the metafunction <a class="link" href="boost__json__is_deallocate_trivial.html" title="is_deallocate_trivial"><code class="computeroutput"><span class="identifier">is_deallocate_trivial</span></code></a> returns <code class="computeroutput"><span class="keyword">true</span></code>.
      </p>
<p>
        The resource is constructed from a caller-owned buffer from which subsequent
        calls to allocate are apportioned. When a memory request cannot be satisfied
        from the free bytes remaining in the buffer, the allocation request fails
        with the exception <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_alloc</span></code>.
      </p>
<h5>
<a name="json.ref.boost__json__static_resource.h3"></a>
        <span class="phrase"><a name="json.ref.boost__json__static_resource.example"></a></span><a class="link" href="boost__json__static_resource.html#json.ref.boost__json__static_resource.example">Example</a>
      </h5>
<p>
        This parses a JSON into a value which uses a local stack buffer, then prints
        the result.
      </p>
<pre class="programlisting"><span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">buf</span><span class="special">[</span> <span class="number">4000</span> <span class="special">];</span>
<span class="identifier">static_resource</span> <span class="identifier">mr</span><span class="special">(</span> <span class="identifier">buf</span> <span class="special">);</span>

<span class="comment">// Parse the string, using our memory resource</span>
<span class="identifier">value</span> <span class="keyword">const</span> <span class="identifier">jv</span> <span class="special">=</span> <span class="identifier">parse</span><span class="special">(</span> <span class="string">"[1,2,3]"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">mr</span> <span class="special">);</span>

<span class="comment">// Print the JSON</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">jv</span><span class="special">;</span>
</pre>
<h5>
<a name="json.ref.boost__json__static_resource.h4"></a>
        <span class="phrase"><a name="json.ref.boost__json__static_resource.thread_safety"></a></span><a class="link" href="boost__json__static_resource.html#json.ref.boost__json__static_resource.thread_safety">Thread
        Safety</a>
      </h5>
<p>
        Members of the same instance may not be called concurrently.
      </p>
<h5>
<a name="json.ref.boost__json__static_resource.h5"></a>
        <span class="phrase"><a name="json.ref.boost__json__static_resource.see_also"></a></span><a class="link" href="boost__json__static_resource.html#json.ref.boost__json__static_resource.see_also">See
        Also</a>
      </h5>
<p>
        <a href="https://en.wikipedia.org/wiki/Region-based_memory_management" target="_top">https://en.wikipedia.org/wiki/Region-based_memory_management</a>
      </p>
<p>
        Convenience header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json.hpp" target="_top">boost/json.hpp</a>&gt;</code>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Vinnie Falco<br>Copyright © 2020 Krystian Stasiowski<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__serializer/read/overload2.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__static_resource/static_resource.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
